let averageTempDay1 = [72, 75, 79, 79, 81, 81]
let averageTempDay2 = [81, 79, 75, 75, 73, 72]

let averageTemp = []

// same as
averageTemp[0] = [72, 75, 79, 79, 81, 81]
averageTemp[1] = [81, 79, 75, 75, 73, 73]

function printMatrix(myMatrix) {
  for (let i = 0; i < myMatrix.length; i++) {
    for (let j = 0; j < myMatrix[i].length; j++) {
      console.log(myMatrix[i][j])
    }
  }
}

// printMatrix(averageTemp)
console.log('averageTemp two-dimensional array:')

// same as

// day 1
averageTemp[0] = []
averageTemp[0][0] = 72
averageTemp[0][1] = 75
averageTemp[0][2] = 79
averageTemp[0][3] = 79
averageTemp[0][4] = 81
averageTemp[0][5] = 81
// day 2
averageTemp[1] = []
averageTemp[1][0] = 81
averageTemp[1][1] = 79
averageTemp[1][2] = 75
averageTemp[1][3] = 75
averageTemp[1][4] = 73
averageTemp[1][5] = 73

// printMatrix(averageTemp)
console.table(averageTemp)

/**
 * --------------------------------------------------------------------------
 * 多维数组
 * --------------------------------------------------------------------------
 */

// Matrix 3x3x3 - Cue

const matrix3x3x3 = []
for (let i = 0; i < 3; i++) {
  matrix3x3x3[i] = []
  for (let j = 0; j < 3; j++) {
    matrix3x3x3[i][j] = []
    for (let k = 0; k < 3; k++) {
      matrix3x3x3[i][j][k] = i + j + k
    }
  }
}

for (let i = 0; i < matrix3x3x3.length; i++) {
  for (let j = 0; j < matrix3x3x3[i].length; j++) {
    for (let z = 0; z < matrix3x3x3[i][j].length; z++) {
      console.log(matrix3x3x3[i][j][z])
    }
  }
}

// user-friendly-output
const matrix3x3x3Output = []
for (let i = 0; i < 3; i++) {
  matrix3x3x3Output[i] = []
  for (let j = 0; j < 3; j++) {
    matrix3x3x3Output[i][j] = `[${matrix3x3x3[i][j].join(', ')}]`
  }
}
console.log('matrix3x3x3 three-dimensional array:')
console.table(matrix3x3x3Output)
